<?php

require_once( '../../libs/smarty.inc' );

require_once( '../../libs/Class_DB.php' );

require_once( '../../libs/login.inc.php' );



if( !in_array( "A", $_SESSION['ADMIN_LOGIN']['AUTH_CD'] ) ) exit;



$id = $_GET['id'];

$no = $_GET['no'];



$db = new Class_DB;



$sql = sprintf("SELECT * FROM D_SAMPLE WHERE id = %u", $id);

$db->query( $sql );



if( !$db->num_rows() ) exit;

$row = $db->fetch();

if( $no == 1 ){

	$filename = $row['filename1'];

}else{

	$filename = $row['filename2'];

}



$fname = $id . '_' . $no;



header("Content-Type: application/octet-stream");

header('Content-Disposition: attachment; filename=' . $filename );



readfile( "../../files/$fname" );

?>